package com.first.orange.service.impl;

import com.first.orange.beans.Orders;
import com.first.orange.beans.Product;
import com.first.orange.beans.UserInformation;
import com.first.orange.mapper.PersonMapper;
import com.first.orange.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * Created on 2021/7/5.
 * <p>
 * Author : Lcywings
 * <p>
 * Description : 个人中心业务实现类
 */
@Service
public class PersonServiceImpl implements PersonService {

    //个人中心数据接口
    @Autowired(required = false)
    PersonMapper personMapper;


    @Override
    //获取个人资产业务实现
    public Map<String, Object> getPersonalAssets(Integer userId) {
        //声明个人资产map
        Map<String, Object> map = new HashMap<>();

        //声明用户信息详情类
        UserInformation userInformation = personMapper.getUserInformation(userId);

        // 获取用户信息详情
        map.put("userInformation", userInformation);
        // 获取账户优惠券数量
        map.put("couponTotal", personMapper.getCouponTotal(userId));

        // 返回数据
        return map;
    }

    @Override
    public Orders getOrders(Integer userId) {
        return personMapper.getOrders(userId);
    }

    @Override
    public Product getProduct(Integer productId) {
        return personMapper.getProduct(productId);
    }
}
